image: "redoxos/redoxer"

variables:
    CARGO_HOME: $CI_PROJECT_DIR/cargo
before_script:
  - apt-get update -qq
  - apt-get install -qq build-essential curl git

format:
  image: 'rustlang/rust:nightly'
  cache:
    key: format
    paths:
      - cargo/
      - target/
  script:
    - rustup default nightly
    - rustup component add rustfmt
    - cargo +nightly fmt --all -- --check

linux:
  image: 'rust:1.53.0'
  cache:
    key: linux
    paths:
      - cargo/
      - target/
  script:
    - cargo check --features=piston
    - FULL=1 make tests

linux:stable:
  cache:
    key: linuxstable
    paths:
      - cargo/
      - target/
  script:
    - cargo check --features=piston
    - TOOLCHAIN= make tests

redox:
  cache:
    key: redox
    paths:
      - cargo/
      - target/
  before_script:
    - apt-get update -qq
    - apt-get install -qq build-essential curl git
  script:
    - redoxer test

link-check:
  image: hrektts/mdbook
  cache:
    key: linkcheck
    paths:
      - cargo/
      - cargo/bin
  before_script:
    - apt-get update -qq
    - apt-get install -qq libssl-dev pkg-config build-essential curl git
    - test -x $CARGO_HOME/bin/mdbook-linkcheck || cargo install mdbook-linkcheck
  script:
  - PATH=$PATH:$CARGO_HOME/bin
  - make manual
  - mdbook build manual

pages:
  image: hrektts/mdbook
  stage: deploy
  cache:
    key: book
    paths:
      - cargo/
      - cargo/bin
  before_script:
    - apt-get update -qq
    - apt-get install -qq libssl-dev pkg-config build-essential curl git
    - test -x $CARGO_HOME/bin/mdbook-linkcheck || cargo install mdbook-linkcheck
  script:
  - PATH=$PATH:$CARGO_HOME/bin
  - make manual
  - mdbook build manual
  - mv manual/book/html public
  artifacts:
    paths:
    - public
  only:
  - master

compare-benchmarks:
  image: rustlang/rust:nightly
  stage: test
  when: manual
  allow_failure: true
  except: [master]
  script:
    - apt-get update && apt-get install -y build-essential libboost-dev jq bc
    - sh ./ci/run_benchmark.sh
  artifacts:
    reports:
      junit: target/report.xml
    paths: [target/criterion]
